// 
// Bachelor of Software Engineering
// Media Design School
// Auckland
// New Zealand
//
// (c) 2005 - 2014 Media Design School
//
// File Name	: SpaceInvadersApp.cpp
// Desrciption	: CSpaceInvadersApp implementation file.
// Author		: Hayden Asplet.
// Mail			: hayden.asplet@mediadesignschool.com
//

// PCH
#include "SpaceInvadersStd.h"

// Library Includes

// This Include
#include "SpaceInvadersApp.h"

// Local Includes
#include "Msvc\resource.h"
#include "SpaceInvadersLogic.h"

CSpaceInvadersApp g_spaceInvadersApp;

CSpaceInvadersApp::~CSpaceInvadersApp()
{
	RemoveFontResourceEx(L"Fonts\\HaxrCorp_S8.fon", FR_PRIVATE, NULL);
}

CGameLogic* CSpaceInvadersApp::VCreateGame()
{
	m_pGame = new CSpaceInvadersLogic();

	if(!m_pGame->VInit()) {
	// Game failed to initialize.
		// De-allocate memory.
		delete m_pGame;

		return NULL;
	}

	return m_pGame;
}

HICON CSpaceInvadersApp::VGetIcon()
{
	return LoadIcon(m_hInstance, MAKEINTRESOURCE(IDI_ICON1)); 
}

TCHAR* CSpaceInvadersApp::VGetTitle()
{
	return L"Space Invaders";
}

CPoint CSpaceInvadersApp::VGetScreenSetupSize()
{
	return CPoint(g_kiSPACEINVADERS_SCREEN_WIDTH, g_kiSPACEINVADERS_SCREEN_HEIGHT);
}

DWORD CSpaceInvadersApp::VGetWindowStyle()
{
	return WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU |WS_VISIBLE;
}

bool CSpaceInvadersApp::VInitialize(HINSTANCE _hInstance, LPSTR _lpCmdLine, HWND _hWnd, int _iFrameRate)
{
	if(!CGameApp::VInitialize(_hInstance, _lpCmdLine, _hWnd, _iFrameRate)) {
		return false;
	}
	else {
		AddFontResourceEx(L"Fonts\\HaxrCorp_S8.fon", FR_PRIVATE, NULL);
	}

	return true;
}